import { getRepaymentProjectInfo } from '@/api/researchManage/projectManage'
import { getBacklogList } from '@/api/researchManage/backlog'

const useResearchProjectStore = defineStore('researchProject', {
  state: () => ({
    projectInfo: {},
    backlogList: [] //需求列表
  }),
  actions: {
    //获取项目信息
    getProjectInfo(projectId) {
      return new Promise((resolve, reject) => {
        getRepaymentProjectInfo(projectId)
          .then(res => {
            // @ts-ignore
            this.projectInfo = res.data
            resolve(res.data)
          })
          .catch(error => {
            reject(error)
          })
      })
    },
    //获取需求列表
    handleGetBacklogList(query) {
      return new Promise((resolve, reject) => {
        getBacklogList(query)
          .then(res => {
            // @ts-ignore
            this.backlogList = res.data
            resolve(res.data)
          })
          .catch(error => {
            reject(error)
          })
      })
    }
  }
})

export default useResearchProjectStore
